import { ElMessage, ElMessageBox } from 'element-plus'

export async function delConfim(callback: () => Promise<boolean>) {
  ElMessageBox.confirm('是否确认删除?', 'Warning', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    const isSuccess = await callback()
    ElMessage({
      type: isSuccess ? 'success' : 'error',
      message: `删除${isSuccess ? '成功' : '失败'}`
    })
  })
}

export async function requestMessage(msg: string, callback: () => Promise<boolean>) {
  const isSuccess = await callback()
  ElMessage({
    type: isSuccess ? 'success' : 'error',
    message: `${msg}${isSuccess ? '成功' : '失败'}`
  })
}
